const fs = require('fs');
const path = require( 'path' );

let target1 = path.resolve(__dirname,'hello.txt');
let target2 = path.resolve(__dirname,'world.txt');

// 异步删除文件
// fs.rm( path [, options] , callback)
fs.rm( target1 , error => {
    if(error){
        console.log( error );
        return;
    }
    console.log(`文件${path.basename(target1)}已删除`);
});

// 同步删除文件
// fs.rmSync( path [, options] )
fs.rmSync( target2 );
console.log(`文件${path.basename(target2)}已删除`);